package javase.collection.map;

import java.util.HashMap;

/**
 * @author hck
 */
public class TestHashMap {
    public static void main(String[] args) {
        //  测试map hash 冲突
        HashMap<User, String> map = new HashMap<>(1);
        User user1 = new User("user1");
        User user2 = new User("user2");
        User user3 = new User("user3");
        map.put(user1, "");
        map.put(user2, "");
        map.put(user3, "");
        System.out.println(user1 == user2);
        System.out.println(user1.equals(user2));
        System.out.println(map);
    }
}

class User {
    private String name;

    public User(String name) {
        this.name = name;
    }

    @Override
    public int hashCode() {
        return 1;
    }
}